
using Crux.Core.Domains;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace Crux.Core.EFCore;
/// <inheritdoc/>
public class ServiceProviderInterceptor(IServiceProvider provider)
    : IMaterializationInterceptor
{
    /// <inheritdoc/>
    public object InitializedInstance(
        MaterializationInterceptionData materializationData,
        object instance)
    {
        if (instance is IInjectServiceProvider entity)
            entity.ServiceProvider = provider;

        return instance;
    }

}